<template>
  <!--为echarts准备一个具备大小的容器dom-->
  <div id="main" style="width: 100%;height: 300px;" />
</template>
<script>
import echarts from 'echarts'
import bus from '../../../common/bus'
export default {
  name: '',
  data() {
    return {
      echarts: {
        title: {
          text: ''
        },
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['Step Start', 'Step Middle', 'Step End']
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: 'Step Start',
            type: 'line',
            step: 'start',
            data: [120, 132, 101, 134, 90, 230, 210]
          },
          {
            name: 'Step Middle',
            type: 'line',
            step: 'middle',
            data: [220, 282, 201, 234, 290, 430, 410]
          },
          {
            name: 'Step End',
            type: 'line',
            step: 'end',
            data: [450, 432, 401, 454, 590, 530, 510]
          }
        ]
      },
      NodeList: ''
    }
  },
  created() {
    bus.$on('EchartsData', msg => {
      console.log('222', msg)
    })
    bus.$on('NodeData', msg => {
      this.$nextTick(function() {
        this.echarts.title.text = msg.node
      })
    })
  },
  mounted() {
    this.$nextTick(function() {
      this.drawPie('main')
    })
    // this.echarts.title.text = this.$store.state.NodeName
    // console.log('NodeName11', this.$store.state.NodeName)
  },
  methods: {
    // 图表渲染
    drawPie(id) {
      this.charts = echarts.init(document.getElementById(id))
      this.charts.setOption(this.echarts)
    }
  }
}
</script>
<style scoped>
    * {
      margin: 0;
      padding: 0;
      list-style: none;
    }
</style>
